package cn.bytecollege.controller;

import cn.bytecollege.service.AdminService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * 删除管理员
 * @author qy
 */
@WebServlet(name = "AdminDeleteController", value = "/AdminDelete")
public class AdminDeleteController extends HttpServlet {
    AdminService adminService = new AdminService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");

        adminService.deleteById(Integer.valueOf(id));

        response.sendRedirect(request.getContextPath()+"/admin/login");
    }
}
